Skip to content

About: Pretty-print (wrap) JSON settings dump#96

Merged
romanlefler merged 1 commit intoromanlefler:developmentfrom
ferdnyc:pretty-json
Jan 26, 2026
Merged

About: Pretty-print (wrap) JSON settings dump#96
romanlefler merged 1 commit intoromanlefler:developmentfrom
ferdnyc:pretty-json

Conversation

@ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Jan 26, 2026

Use the three-argument form of JSON.stringify() to dump the settings object line-wrapped and with 1-space indents, for readability when pasted into bug reports (or anywhere else).

For example, in my recently-opened issue, instead of this:

Settings

{"details-list":"['conditionText', 'windSpeedAndDir', 'sunrise', 'humidity', 'feelsLike', 'gusts', 'sunset', 'precipitation']","theme":"''","show-suntime":"false","secondary-panel-detail":"''","is-activated":"true","panel-priority":"0","panel-box":"'center'","panel-offset":"20.0","main-location-index":"0","my-loc-provider":"'disable'","unit-preset":"'us'","app-version":"49.2.0","gnome-version":"49.2","user-locale":"en-US"}

the pasted dump would look like this:

Settings

{
 "details-list": "['conditionText', 'windSpeedAndDir', 'sunrise', 'humidity', 'feelsLike', 'gusts', 'sunset', 'precipitation']",
 "theme": "''",
 "show-suntime": "false",
 "secondary-panel-detail": "''",
 "is-activated": "true",
 "panel-priority": "0",
 "panel-box": "'center'",
 "panel-offset": "20.0",
 "main-location-index": "0",
 "my-loc-provider": "'disable'",
 "unit-preset": "'us'",
 "app-version": "49.2.0",
 "gnome-version": "49.2",
 "user-locale": "en-US"
}

(I don't love that the entire details-list is still dumped onto a single line, but that's a consequence of the Record<string, string> type of the temporary object, and the value of details-list (an (as)-format GVariant) having already been dumped to string form using GVariant::print().)

Use the three-argument form of `JSON.stringify()` to dump the
settings object line-wrapped and with 1-space indents, for
readability when pasted into bug reports (or anywhere else).
@romanlefler romanlefler added the enhancement New feature or request label Jan 26, 2026
@romanlefler
Copy link
Owner

Good idea, thank you for contributing.

@romanlefler romanlefler merged commit ba2c412 into romanlefler:development Jan 26, 2026
1 check passed
@ferdnyc ferdnyc deleted the pretty-json branch January 28, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants